[DF] Support for RHist with VariationsFor (on root master) - #22956
[DF] Support for RHist with VariationsFor (on root master)#22956gpetruc wants to merge 3 commits into
Conversation
| template<typename B> | ||
| void addCopyForVariations(std::vector<std::shared_ptr<ROOT::Experimental::RHist<B>>> &vec, const ROOT::Experimental::RHist<B> & obj) | ||
| { | ||
| // Note that Clone() returns a value and not a pointer, so we call 'new' and pass that value to the RHist move constructor |
There was a problem hiding this comment.
Maybe I'm misunderstanding the comment but I don't see new being called. I believe this is a valid use of the Clone method.
There was a problem hiding this comment.
right, when I wrote the comment I still had emplace_back(new T{x.Clone()}, then later I replaced the new with a make_shared and didn't update the comment.
Test Results 23 files 23 suites 3d 16h 36m 12s ⏱️ Results for commit 0803f5a. |
hahnjo
left a comment
There was a problem hiding this comment.
LGTM, but I won't officially approve since it's only RDF code. We may want to document that a user-provided RHist / RHistEngine will end up being used for the nominal result, and the variations will start from fresh ones. Also one inline comment for a potential simplification.
| template <typename T> | ||
| void addCopyForVariations(std::vector<std::shared_ptr<T>> &vec, const T & obj) | ||
| { | ||
| vec.emplace_back(std::make_shared<T>(obj)); | ||
| } |
There was a problem hiding this comment.
To simplify / remove duplicate code, you could change to
| template <typename T> | |
| void addCopyForVariations(std::vector<std::shared_ptr<T>> &vec, const T & obj) | |
| { | |
| vec.emplace_back(std::make_shared<T>(obj)); | |
| } | |
| template <typename T> | |
| std::shared_ptr<T> copyForVariations(const T & obj) | |
| { | |
| return std::make_shared<T>(obj); | |
| } |
and push it into the vector at the call site.
Support for RHist with VariationsFor
Changes or fixes:
In order to allow VariationsFor on RHist, this PR does two things:
Clone()onRHistandRHistEnginethat are non-copiable.MakeNewmethod forRHistFillHelperandRHistEngineFillHelperBoth changes are trivial, all the existing logic for VariationsFor, copying and filling RHists is unchanged.
To check that the code compiles and run, two unit tests are added, for
RHistFillHelperandRHistEngineFillHelper.No attempt is made of testing
VariationsForon all possible code paths (JIT vs compile time, 1D vs multi-D, weights vs no weights, etc.) because the code changes are agnostic to all that.This PR is based on the current master, but I have also a branch on top of #22899 from @hahnjo : the two features are orthogonal, but some trivial merge conflicts are expected in the unit tests.
Checklist:
ctest -R gtest-tree-dataframe-dataframe-histThis PR fixes #22954